package request;

import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * 获取请求体数据：
 *              1.获取流对象
 *                          BufferedReader getReader():获取字符输入流，只能操作字符数据
 *                          ServletInputStream getInputSteam: 获取字节输入流，可以操作所有类型数据
 *              2.从流中拿数据
 */
@WebServlet("/request_demo3")
public class request_demo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求的参数
        /**
         * get:request.getQueryString()
         * post:request.getReader()
         */
        BufferedReader br = request.getReader();
        //读取数据
        String line = null;
        while ((line = br.readLine())!=null){
            System.out.println(line);
        }
    }
}
